/**
 * 
 */
package com.gragra.clustering.tests;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import com.gragra.clustering.DivisiveKMeansBasedClustering;
import com.gragra.data.MixingCorpus;
import com.gragra.data.MixingCorpusBaseImplementation;
import com.gragra.distances.CosineMeanFactory;
import com.gragra.sampling.ThreadedUniformAccess;
import com.gragra.sampling.vector.VectorStructure;
import com.gragra.util.StringToInt;
/**
 * @author Christoph Teichmann
 * created May 6, 2013 2:47:20 PM
 * @version 0.1
 */
public class TestDivisiveKMeansBasedClustering
{
	/**
	 * 
	 */
	private DivisiveKMeansBasedClustering dkb;
	/**
	 *
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception
	{dkb = new DivisiveKMeansBasedClustering(2, new CosineMeanFactory(), 10);}
	/**
	 * Test method for {@link com.gragra.clustering.DivisiveKMeansBasedClustering#getBest(com.gragra.sampling.vector.VectorStructure, int)}.
	 */
	@Test
	public final void testGetBest()
	{
		MixingCorpus<VectorStructure> data = new MixingCorpusBaseImplementation<VectorStructure>();
		data.addData(new VectorStructure(StringToInt.ensure("first"), new double[] {1.0,4.0,7.0}, new int[][] {{1,1},{2,1},{1,2}},2));
		data.addData(new VectorStructure(StringToInt.ensure("second"), new double[] {2.0,8.0,14.0}, new int[][] {{1,1},{2,1},{1,2}},2));
		data.addData(new VectorStructure(StringToInt.ensure("third"), new double[] {2.0,3.0,4.0}, new int[][] {{1,4},{2,2},{1,3}},2));
		data.addData(new VectorStructure(StringToInt.ensure("fourth"), new double[] {2.0,5.0,3.0}, new int[][] {{1,4},{2,2},{1,3}},2));
		data.addData(new VectorStructure(StringToInt.ensure("fifth"), new double[] {10.0,5.0,2.5}, new int[][] {{1,4},{2,2},{1,3}},2));
		data.addData(new VectorStructure(StringToInt.ensure("sixth"), new double[] {5.0,2.5,1.25}, new int[][] {{1,4},{2,2},{1,3}},2));
		dkb.cluster(data, new ThreadedUniformAccess(1));
		assertTrue(dkb.getBest(data.getEntry(0), 0) != dkb.getBest(data.getEntry(2), 2));
	}
}
